﻿@helper GenerateEditor(Type type, Dictionary<string, List<SelectListItem>> selects)
{
	<div class="form-horizontal">
		<h4>PipingMaterialsClassData</h4>
		<hr />
		@Html.ValidationSummary("", true,  new { @class = "text-danger" })
		@Html.Hidden("typeName", type.Name)

		@foreach (var prop in type.GetProperties())
		{
			var val = type.GetProperty(prop.Name).GetValue(Model);

			if (selects.ContainsKey(prop.Name))
			{
				<div class="form-group">
					@Html.Label(prop.Name, attributes: new { @class = "control-label col-md-3" })
					<div class="col-md-9 dropdown">
						@Html.DropDownList(prop.Name, "", selects["MaterialsOfConstructionClass"], "", new { htmlAttributes = new { @class = "form-control" } })
					</div>
				</div>
			}
			else
			{
				<div class="form-group">
					@Html.Label(prop.Name, attributes: new { @class = "control-label col-md-3" })
					<div class="col-md-9">
						<input class="form-control" type="text" name="@prop.Name" value="@val" />
						@Html.ValidationMessage(prop.Name, "", new { @class = "text-danger" })
					</div>
				</div>
			}
		}

		<div class="form-group">
			<div class="col-md-offset-2 col-md-9">
				<input type="submit" value="Create" class="btn btn-default" />
			</div>
		</div>
	</div>
}